﻿Public Class clsLhPgd
    Public Function getLhPgd() As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT a.*,b.start_time,b.end_time FROM sf.b_pgd_lh_details a "
        szSql &= "left join sf.b_pgd_mes b on a.b_pgd_mes_sys_id = b.sys_id "
        'szSql &= "left join sf.t_hw_setting c on a.lhj = c.equip_id "
        szSql &= " WHERE 1 = 1 "
        szSql &= " and a.factory_id = ? "
        szSql &= " and now() between b.start_time and b.end_time "
        szSql &= " and a.validity = ? "
        szSql &= " and a.lhj_finish_count < a.oper_count "
        'szSql &= " And c.status = ? "
        szSql &= " ORDER BY a.oper_date ASC"
        'Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, "TS", startTime, endTime, "1", "0")
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, "TS", "1")
        If IsNothing(dt) Then
            getLhPgd = New DataTable
        Else
            getLhPgd = dt
        End If
    End Function

    Public Function getLhPgd1(startTime As String, endTime As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT a.*,b.start_time,b.end_time FROM sf.b_pgd_lh_details a "
        szSql &= "left join sf.b_pgd_mes b on a.b_pgd_mes_sys_id = b.sys_id "
        'szSql &= "left join sf.t_hw_setting c on a.lhj = c.equip_id "
        szSql &= " WHERE 1 = 1 "
        szSql &= " and a.factory_id = ? "
        If startTime <> "" Then
            szSql &= " and b.start_time = ? "
        End If
        If endTime <> "" Then
            szSql &= " and b.end_time = ? "
        End If
        szSql &= " and a.validity = ? "
        szSql &= " and a.lhj_finish_count < a.oper_count "
        'szSql &= " And c.status = ? "
        szSql &= " ORDER BY a.oper_date ASC"
        'Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, "TS", startTime, endTime, "1", "0")
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, "TS", startTime, endTime, "1")
        If IsNothing(dt) Then
            getLhPgd1 = New DataTable
        Else
            getLhPgd1 = dt
        End If
    End Function


    Public Function getLhPgdById(id As String) As DataTable
        Dim szSql As String = "SELECT * FROM sf.b_pgd_lh_details WHERE sys_id = ? "
        Dim dt As DataTable = DBacs.ExecuteSql(szSql, -1, id)
        Return dt
    End Function
End Class
